/*
 * @Description: 提交按钮部件
 * @Author: paddies
 * @Date: 2023-06-15 21:59:44
 * @LastEditors: paddies
 * @LastEditTime: 2024-07-01 19:24:26
 * @FilePath: /luntai-user-app/Users/paddies/Desktop/code/A-team/luntai/shared_components/lib/build-button/buildButton.dart
 */
import 'package:flutter/material.dart';

Color disabledColor = Color(0xffa1a1a1);
//  border: Border(
//                                   left: BorderSide(
//                                       width: 1.0, color: activeColor),
//                                   top: BorderSide(
//                                       width: 1.0, color: activeColor),
//                                   right: BorderSide(
//                                       width: 1.0, color: activeColor),
//                                   bottom: BorderSide(
//                                       width: 1.0, color: activeColor)),
Widget buildButton(
    {String title = "默认按钮",
    bool disabled = false,
    double fontSize = 18,
    Border border = const Border(),
    double borderRadius = 20,
    double height = 60,
    Color fontColor = Colors.white,
    FontWeight fontWeight = FontWeight.w400,
    List<Color>? colors,
    Function? onClick}) {
  if (colors == null) {
    colors = [
      Color(0xffF0C322),
      Color(0xffD45228),
    ];
  }

  if (disabled) {
    colors = [
      Color(0xff8C8C8C),
      Color(0xff8C8C8C),
    ];
  }

  return Container(
    width: double.infinity,
    height: height,
    // color: Colors.red,
    child: GestureDetector(
        onTap: () {
          if (!disabled && onClick != null) {
            onClick();
          }
        },
        child: Container(
            width: double.infinity,
            height: double.infinity,
            alignment: Alignment.center,
            // margin: const EdgeInsets.only(right: 20, left: 20, bottom: 30),
            decoration: BoxDecoration(
                borderRadius:
                    BorderRadius.all(Radius.circular(borderRadius)), //圆角
                border: border,
                gradient: LinearGradient(
                    begin: Alignment.topLeft, //渐变开始于上面的中间开始
                    end: Alignment.topRight, //渐变结束于下面的中间
                    colors: colors //开始颜色和结束颜色])),
                    )),
            child: Text(
              title,
              style: TextStyle(
                  color: fontColor, fontSize: fontSize, fontWeight: fontWeight),
            ))),
  );
}
